change an array depending on whether the checkbox is checked or unchecked using vanilla JavaScript